﻿using System.Windows;
using System.Windows.Forms;
using GemGui.ViewModel;

namespace GemGui
{
    /// <summary>
    /// Interaction logic for ConfigureWindow.xaml
    /// </summary>
    public partial class ConfigureWindow : Window
    {
        public ConfigureWindow()
            : this(null)
        {
        }

        public ConfigureWindow(ConfigurationViewModel viewModel)
        {
            ViewModel = viewModel ?? new ConfigurationViewModel() { MaxSearchDepth = 1 };

            InitializeComponent();
        }

        #region Visual Properties

        /// <summary>
        /// Gets the view model for this dialog.
        /// </summary>
        public ConfigurationViewModel ViewModel { get; private set; }

        #endregion

        private void BtnBrowse_Click(object sender, RoutedEventArgs e)
        {
            var chooseFolderDialog = new FolderBrowserDialog { SelectedPath = ViewModel.RootFolderForSearch };

            if (chooseFolderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ViewModel.RootFolderForSearch = chooseFolderDialog.SelectedPath;
            }
        }

        private void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }
    }
}
